﻿//using System;
//using System.ServiceModel;
//using System.ServiceModel.Description;
//using System.ServiceModel.Routing;
//using EasyComm.Hosting.Behavior;

//namespace EasyComm.Hosting.Configuration
//{
//    internal static class RouterConfiguration
//    {
//        internal static void ApplyConfiguration(ServiceHost serviceHost, Type serviceType, Type[] serviceContractList, Uri[] baseAddresses, Uri discoveryProxyAddress, string ns = "http://www.tempuri.org/")
//        {
//            if (serviceHost == null)
//            {
//                return;
//            }
//            ContractDescription desc = ContractDescription.GetContract(typeof(IRequestReplyRouter), serviceType); //GenericConfiguration.CreateContractDescription(serviceType, serviceContract, ns);
//            //ContractDescription desc = GenericConfiguration.CreateContractDescription(serviceType, serviceContract, ns);

//            #region main endpoints
//            for (int i = 0; i < baseAddresses.Length; i++)
//            {
//                ServiceEndpoint mainEndPoint = new ServiceEndpoint(desc, GenericConfiguration.GetMainBinding(), new EndpointAddress(baseAddresses[i]));
//                mainEndPoint.Name = string.Format("{0}_MainEndpoint_{1}", serviceType.Name, i);
//                serviceHost.AddServiceEndpoint(mainEndPoint);
//            }
//            #endregion

//            // add the routing configuration 
//            serviceHost.Description.Behaviors.Add(new RoutingBehavior(new RoutingConfiguration()));

//            // add the discovery behavior
//            serviceHost.Description.Behaviors.Add(new DiscoveryRouterBehavior(serviceContractList, discoveryProxyAddress));

//            // ** DISCOVERY ** //
//            //ServiceDiscoveryBehavior discoveryBehavior = new ServiceDiscoveryBehavior();
//            //discoveryBehavior.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint());
//            //serviceHost.Description.Behaviors.Add(discoveryBehavior);
//            //serviceHost.AddServiceEndpoint(new UdpDiscoveryEndpoint() { Name = "udpDiscoveryEndPoint" });

//            //general
//            GenericConfiguration.SetupMex(serviceHost, serviceType, "routerMexUrl");
//            GenericConfiguration.SetupDebugging(serviceHost);
//            //System.ServiceModel.ServiceHostingEnvironment.MultipleSiteBindingsEnabled = true;
//        }
//    }
//}
